/***
 * 登录接口处理
 */
//登录
import {reactive,ref} from "vue";
import router from "@/router.js";
import AMap from "@/assets/js/common/AMap.js";
import {UpdataLogin,GetCaptchaGetCode,UpdataUserLogout} from "@/api/login.js";//接口地址

export class Login {
    constructor() {
        //parameters
    }
    public config=reactive({ //初始化值
            passwordType:"password",
            sliderText: "拖动滑块完成验证",
            isShow: false, // 验证码模态框是否出现
            isGetCocing: false,
            codeText: "获取验证码",
            time: 59,
            timer: undefined,
            reg: /^1[0-9]{10}$/, // 手机号码匹配正则
            pas: /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[@#&_-])[\da-zA-Z@#&_-]{8,}$/, //密码强度不符合
            year: "",
            status: 1,
            phone: "admin",
            captcha:"",
            password: "000000",
            codeImg:"",
            requestId:""
        })

    /**
     * //获取图形验证码
     */
    public getCaptchaGetCode() {
        GetCaptchaGetCode({},res=>{
            this.config.codeImg=res.data.base64Code;
            this.config.requestId=res.data.requestId;
          })
    }   

    /**
     * 点击登录
     */
     public updataLogin() {
        console.log("登录")
        localStorage.setItem("authorization",{user:"dogface"});
        router.push({ path: "/" });//测试
        // UpdataLogin({},res=>{
        //     this.config.codeImg=res.data.base64Code;
        //     this.config.requestId=res.data.requestId;
        //   })
    }  

    
    /**
     * //退出登录
     */
     public updataUserLogout() {
        UpdataUserLogout({},res=>{
            this.config.codeImg=res.data.base64Code;
            this.config.requestId=res.data.requestId;
          })
    }  

}  

export const LoginClass=new Login();